#pragma once

#include <pthread.h>
#include <string>
#include <cstdio>

typedef void*(*func_t)(void*);

class Thread_Data
{
public:
    std::string name;
    void* args;
};

class Thread
{
public:
    Thread(int num, func_t func, void* args) : _func(func) 
    {
        std::string name = "thread ";
        name += std::to_string(num);
        _data.name = name;
        _data.args = args;
    }

    void run()
    {
        pthread_create(&_tid, nullptr, _func, (void*)&_data);
    }

    void join()
    {
        pthread_join(_tid, nullptr);
    }

    std::string name()
    {
        return _data.name;
    }

    ~Thread()
    {}
private:
    pthread_t _tid;
    Thread_Data _data;
    func_t _func;
};